
#include "gtest/gtest.h"

#include "MaxHeap.h"

TEST( MaxHeapTest, Simple )
{
    MaxHeap<int> H(4);
    int x;

    H.Insert(10).Insert(20).Insert(5);
    H.Insert(15);
    EXPECT_THROW( H.Insert(30), class NoMem );

    EXPECT_EQ( 4, H.Size() );

    H.DeleteMax( x );
    EXPECT_EQ( 20, x );

    H.DeleteMax( x );
    EXPECT_EQ( 15, x );

    H.DeleteMax( x );
    EXPECT_EQ( 10, x );

    H.DeleteMax( x );
    EXPECT_EQ( 5, x );

    EXPECT_EQ( 0, H.Size() );
}

#include "main_stub.h"

